{{ template "head" .Global}}




        <!--DataTables example-->
        <div id="table-datatables">
            <h4 class="header">用户列表 <a href="#adduser"
                                       class="btn dropdown-button waves-effect waves-light modal-trigger"
                                       style="float:right">添加</a>


            </h4>

            <div class="row">
                <div class="col s12 m12 l12">
                    <table id="data-table-simple" class="responsive-table display" cellspacing="0">

                        <thead>
                        <tr>
                            <th>用户ID</th>
                            <th>用户名</th>
                            <th>角色</th>
                            <th>状态</th>
                            <th>最近登录</th>
                            <th>创建时间</th>
                            <th>修改密码</th>
                            <th>删除</th>

                        </tr>
                        </thead>

                        <tbody>


                        {{range $k,$v :=$.UserAll}}
                        <tr>
                            <td>{{$v.id}}</td>
                            <td>{{$v.user_name}}</td>

                            {{range $k1,$v1 :=$.RoleAll }} {{if eq $v1.id $v.role_id}}

                            <td title="点击更改角色"><a href="#role_edit" class="modal-trigger"
                                                  onclick="sys_user_role_passwd_edit({{$v.id}},{{$v.user_name}})">{{$v1.role_name}}</a>
                            </td>
                            {{end}}{{end}}

                            {{if eq $v.status "0"}}
                            <td title="点击禁用"><a style="color: #0f9d58" href="#" onclick="sys_user_disable({{$v.id}})">正常</a>
                            </td>
                            {{else if eq $v.status "1"}}
                            <td title="点击启用"><a style="color: #cc0000" href="#" onclick="sys_user_enable({{$v.id}})">禁用</a>
                            </td>
                            {{end}}

                            <td>{{$v.login_time}}</td>
                            <td>{{$v.create_time}}</td>

                            <td>
                                <a a href="#modif_password"
                                   class="btn dropdown-button waves-effect waves-light modal-trigger "
                                   onclick="sys_user_role_passwd_edit({{$v.id}},{{$v.user_name}})">修改密码</a>
                            </td>
                            <td onclick="sys_post_del_user(this,{{$v.id}})">
                                <a a href="#" class="btn dropdown-button waves-effect waves-light ">删除</a>
                            </td>


                        </tr>
                        {{end}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <br>


    </div>
    <!-- Floating Action Button -->
    <div class="fixed-action-btn" style="bottom: 50px; right: 19px;">
        <a class="btn-floating btn-large">
            <i class="mdi-action-stars"></i>
        </a>
        <ul>
            <li><a href="css-helpers.html" class="btn-floating red"><i
                    class="large mdi-communication-live-help"></i></a></li>
            <li><a href="app-widget.html" class="btn-floating yellow darken-1"><i
                    class="large mdi-device-now-widgets"></i></a></li>
            <li><a href="app-calendar.html" class="btn-floating green"><i
                    class="large mdi-editor-insert-invitation"></i></a></li>
            <li><a href="app-email.html" class="btn-floating blue"><i class="large mdi-communication-email"></i></a>
            </li>
        </ul>
    </div>
    <!-- Floating Action Button -->
</div>
<!--end container-->

</section>
<!-- END CONTENT -->

<div id="role_edit" class="modal">
    <form role="form">
        <div class="modal-content">
            <div class="row">
                <p>
                    <strong>用户角色编辑</strong>
                </p>
            </div>
            <div class="row">
                <div class="input-field col s6" style="display: none">
                    <input type="text" name="id" id="id">
                    <label for="id">用户ID</label>
                </div>

                <div class="input-field col s6">
                    <input type="text" name="username" id="edit_username" class="validate" disabled>
                </div>


                <div class="input-field col s6">
                    <label></label>
                    <select name="value" id="edit_role_id">
                        <option value="" disabled selected>选择角色</option>
                        {{range $k,$v :=$.RoleAll}}
                        <option value="{{$v.id}}">{{$v.role_name}}</option>
                        {{end}}
                    </select>
                </div>
            </div>
        </div>

        <div class="modal-footer">
            <a class="waves-effect waves-red btn-flat modal-action modal-close">关闭</a>
            <a class="waves-effect waves-green btn-flat modal-action" onclick="sys_post_edit_user()">更改</a>
        </div>
    </form>
</div>

<div id="adduser" class="modal">
    <form  role="form">
        <div class="modal-content">
            <div class="row">
                <p>
                    <strong>添加用户</strong>
                </p>
            </div>
            <div class="row">
                <div class="input-field col s6">
                    <input type="text" name="username" id="username">
                    <label for="username">用户名</label>
                </div>


                <div class="input-field col s6">
                    <label></label>
                    <select name="role_id" id="role_id">
                        <option value="" disabled selected>选择角色</option>
                        {{range $k,$v :=$.RoleAll}}
                        <option value="{{$v.id}}">{{$v.role_name}}</option>
                        {{end}}
                    </select>
                </div>


            </div>
            <div class="row">
                <div class="input-field col s6">
                    <input type="password" name="password" id="password">
                    <label for="password">密码（不能少于8位字符）</label>
                </div>

                <div class="input-field col s6">
                    <input type="password" name="password_confirm" id="password_confirm">
                    <label for="password_confirm">确认密码</label>
                </div>

            </div>

        </div>

        <div class="modal-footer">
            <a class="waves-effect waves-red btn-flat modal-action modal-close">关闭</a>
            <a type="submit" class="waves-effect waves-green btn-flat modal-action" onclick="sys_post_add_user()">
                保存
            </a>
        </div>
    </form>
</div>


<div id="modif_password" class="modal">
    <form role="form">
        <div class="modal-content">
            <div class="row">
                <p>
                    <strong>密码修改</strong>
                </p>
            </div>
            <div class="row">
                <div class="input-field col s6" style="display: none">
                    <input type="text" id="modif_password_id">
                </div>

                <div class="input-field col s6">
                    <input type="text" id="modif_password_username" disabled>
                </div>

            </div>
            <div class="row">
                <div class="input-field col s6">
                    <input type="password" name="password" id="modif_password_password">
                    <label for="modif_password">密码（不能少于8位字符）</label>
                </div>

                <div class="input-field col s6">
                    <input type="password" name="password_confirm" id="modif_password_confirm">
                    <label for="modif_password_confirm">确认密码</label>
                </div>

            </div>

        </div>

        <div class="modal-footer">
            <a class="waves-effect waves-red btn-flat modal-action modal-close">关闭</a>
            <a class="waves-effect waves-green btn-flat modal-action" onclick="sys_user_modif_password()">更改</a>
        </div>
    </form>
</div>

{{ template "foot" .Global}}
<script type="text/javascript" src="/statics/js/function.js"></script>
<!-- jQuery Library -->
<script type="text/javascript" src="/statics/js/plugins/jquery-1.11.2.min.js"></script>
<!--materialize js-->
<script type="text/javascript" src="/statics/js/materialize.min.js"></script>
<!--prism-->
<script type="text/javascript" src="/statics/js/plugins/prism/prism.js"></script>
<!--scrollbar-->
<script type="text/javascript" src="/statics/js/plugins/perfect-scrollbar/perfect-scrollbar.min.js"></script>
<!-- data-tables -->
<script type="text/javascript" src="/statics/js/plugins/data-tables/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/statics/js/plugins/data-tables/data-tables-script.js"></script>
<!-- chartist -->
<script type="text/javascript" src="/statics/js/plugins/chartist-js/chartist.min.js"></script>
<!--sweetalert -->
<script type="text/javascript" src="/statics/js/plugins/sweetalert/sweetalert.min.js"></script>
<!--plugins.js - Some Specific JS codes for Plugin Settings-->
<script type="text/javascript" src="/statics/js/plugins.min.js"></script>
<!--custom-script.js - Add your own theme custom JS-->
<script type="text/javascript" src="/statics/js/custom-script.js"></script>
<script type="text/javascript">
    /*Show entries on click hide*/
    $(document).ready(function () {
        $(".dropdown-content.select-dropdown li").on("click", function () {
            var that = this;
            setTimeout(function () {
                if ($(that).parent().hasClass('active')) {
                    $(that).parent().removeClass('active');
                    $(that).parent().hide();
                }
            }, 100);
        });
    });
</script>
</body>

</html>